From d2014a6084bb5f3c4fb0cc0e74f189b088e6f577 Mon Sep 17 00:00:00 2001 From: Richard Hult Date: Mon, 7 Aug 2006 16:45:16 +0000 Subject: [PATCH] Don't get and release the context for each point, just once, speeds up 2006-08-07 Richard Hult * gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't get and release the context for each point, just once, speeds up drawing many points a lot. --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ gdk/quartz/gdkdrawable-quartz.c | 15 ++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d0391d99f..fe30f5f1ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-08-07 Richard Hult + + * gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't + get and release the context for each point, just once, speeds up + drawing many points a lot. + 2006-08-07 Michael Natterer * gtk/gtkdnd-quartz.c (gtk_drag_dest_unset): need to disconnect diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 0d0391d99f..fe30f5f1ce 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2006-08-07 Richard Hult + + * gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't + get and release the context for each point, just once, speeds up + drawing many points a lot. + 2006-08-07 Michael Natterer * gtk/gtkdnd-quartz.c (gtk_drag_dest_unset): need to disconnect diff --git a/gdk/quartz/gdkdrawable-quartz.c b/gdk/quartz/gdkdrawable-quartz.c index f256262555..94b68c8e36 100644 --- a/gdk/quartz/gdkdrawable-quartz.c +++ b/gdk/quartz/gdkdrawable-quartz.c @@ -326,15 +326,24 @@ gdk_quartz_draw_points (GdkDrawable *drawable, GdkPoint *points, gint npoints) { + CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE); int i; + if (!context) + return; + + gdk_quartz_update_context_from_gc (context, gc); + gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (drawable), + _gdk_gc_get_fg_pixel (gc)); + /* Just draw 1x1 rectangles */ for (i = 0; i < npoints; i++) { - gdk_draw_rectangle (drawable, gc, TRUE, - points[i].x, points[i].y, - 1, 1); + CGRect rect = CGRectMake (points[i].x + 0.5, points[i].y + 0.5, 1, 1); + CGContextFillRect (context, rect); } + + gdk_quartz_drawable_release_context (drawable, context); } static void -- 2.30.2